<template>
  <div class="todo-footer">
    <label>
      <!-- <input type="checkbox" :checked="todoSize === todoTotal" @input="todocheckedAll" /> -->
      <input type="checkbox" v-model="istodo" />

    </label>
    <span>
      <span>已完成{{ todoSize }}</span> / 全部{{ todoTotal }}
    </span>
    <button class="btn btn-danger" @click="todoClearFinish">清除已完成任务</button>
  </div>
</template>

<script>
export default {
  name: 'Footer',
  props: ['updataFinish', 'arrlist', 'updatatodocheckedAll'],
  computed: {
    // 总数据的条数
    todoTotal() {
      return this.arrlist.length
    },
    todoSize() {
      // 遍历,拿到所有done为true的数据,
      return this.arrlist.filter(item => item.done).length
    },
    istodo: {
      get() {
        return this.todoSize === this.todoTotal
      },
      set(val) {
        console.log(val);
        this.updatatodocheckedAll(val);
      }
    }
  },
  methods: {
    // 清楚已经勾选任务函数的回调
    todoClearFinish(id) {
      this.updataFinish(id);
    },
    // todocheckedAll(e) {
    //   // console.log(e.target.checked);
    //   this.updatatodocheckedAll(e.target.checked);
    // }
  },

}
</script>

<style scoped>
/*footer*/
.todo-footer {
  height: 40px;
  line-height: 40px;
  padding-left: 6px;
  margin-top: 5px;
}

.todo-footer label {
  display: inline-block;
  margin-right: 20px;
  cursor: pointer;
}

.todo-footer label input {
  position: relative;
  top: -1px;
  vertical-align: middle;
  margin-right: 5px;
}

.todo-footer button {
  float: right;
  margin-top: 5px;
}
</style>